home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / AttackList1.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.6 KB  |  200 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. UIFIELDS
  7. {
  8. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  9. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  10.  
  11. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  12. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  13. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  14. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  15. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  16.                                                     // and other things.  It indicates a general level of combat experience.
  17. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?
  18.         
  19. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  20. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  21. FIELD<INT,    groupToAttack,"what group of objects am I attacking?",12>;
  22.  
  23. }
  24.  
  25.  
  26. fsm Generic_AttackList : integer;
  27.  
  28.  
  29. //------------------------------------------------------------------
  30.  
  31. // Generic_AttackList:
  32. //   This script can be used to attack (or defend) a series of targets
  33. //   contained in a group.  The unit will use a specified tactic
  34. //   on the first living target in the group, and if that unit is
  35. //   destroyed, it will switch to the next one.  When there are no
  36. //   units left in the group, it will go on a rampage, attacking
  37. //   any enemies it can find.
  38.  
  39. //------------------------------------------------------------------
  40.  
  41.  
  42. //------------------------------------------------------------------
  43. //     Constants
  44. //------------------------------------------------------------------
  45.  
  46.     const
  47.         #include_ <content\ABLScripts\mwconst.abi>
  48.  
  49. //------------------------------------------------------------------
  50. //     Types
  51. //------------------------------------------------------------------
  52.  
  53.     type
  54.         #include_ <content\ABLScripts\mwtype.abi>
  55.     
  56.  
  57. //------------------------------------------------------------------
  58. //     Variables
  59. //------------------------------------------------------------------
  60.  
  61.     var
  62.         static integer            AttackRange;        // When all my targets are destroyed, at what range do I start shooting?
  63.  
  64.         static integer            myGroupID;            // The ID of my group ... i.e. this script will
  65.                                                     // call GroupObjectID(groupID)
  66.         static integer            tactic;                // The tactic to use to attack (or defend) my targets
  67.                                                                     
  68.         static integer            piloting;            // Piloting skill
  69.         static integer            gunnery;            // Gunnery skill/chance to hit
  70.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  71.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  72.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  73.                                                     // and other things.  It indicates a general level of combat experience.
  74.         static integer            attackThrottle;        // My attack throttle
  75.  
  76.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  77.  
  78.         static integer             attackSound;        // The attack sound I play when I first attack
  79.         static integer             deathSound;            // The sound I play when I die
  80.         
  81.         static integer            mood;                // My default mood.
  82.  
  83.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  84.  
  85. //------------------------------------------------------------------
  86. //     Init: my initialization function
  87. //------------------------------------------------------------------
  88.  
  89. function Init;
  90.     code
  91.     
  92.         // Variables set by editor
  93.         attackRange        = <attackRange>;
  94.         withdrawRange    = <withdrawRange>;
  95.         takeOffDistance    = <takeOffDistance>;
  96.          piloting        = <piloting>;
  97.         gunnery            = <gunnery>;
  98.         minDelay        = <minDelay>;
  99.         maxDelay        = <maxDelay>;
  100.         eliteLevel        = <eliteLevel>;
  101.         isShotRadius    = <isShotRadius>;
  102.     attackThrottle    = <attackThrottle>;
  103.         myGroupID            = <groupToAttack>;
  104.         
  105.                                                                         
  106.         tactic                = TACTIC_PICK_BEST;
  107.         attackSound        = -1; // no sound
  108.         deathSound        = -1; // no sound
  109.         mood            = NEUTRAL_START;
  110.  
  111. endfunction;
  112.  
  113. //------------------------------------------------------------------
  114. //    StartState: my initial state
  115. //------------------------------------------------------------------
  116.  
  117. state StartState;
  118.  
  119.     code
  120.         SetFiringDelay            (ME,minDelay,maxDelay);
  121.         SetIgnoreFriendlyFire    (ME,true);
  122.         SetIsShotRadius            (ME,isShotRadius);
  123.         SetEntropyMood            (ME,mood);
  124.         SetCurMood                (ME,mood);
  125.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  126.         SetAttackThrottle        (ME,attackThrottle);
  127.                 
  128.         if (orderTakeOff(takeOffDistance) == true) then
  129.             trans AttackFirstLivingTargetState;
  130.         endif;
  131.  
  132. endstate;            
  133.  
  134. //------------------------------------------------------------------
  135. //    AttackFirstLivingTargetState: get the first object in my group, set
  136. //  it as my target, and issue the attack order with my tactic
  137. //------------------------------------------------------------------
  138.  
  139. state AttackFirstLivingTargetState;
  140.  
  141.     var
  142.         ObjectID next_target;
  143.  
  144.     code
  145.         if (GetTarget(ME) == NO_UNIT) then
  146.             next_target = GroupGetFirstObject(GroupObjectID(myGroupID));
  147.  
  148.             if (next_target == NO_UNIT) then
  149.                 trans RampageState;
  150.             endif;
  151.  
  152.             SetTarget(ME,next_target);
  153.         endif;
  154.  
  155.         if (attackSound <> -1) then    
  156.             PlaySoundOnce(attackSound);
  157.         endif;
  158.  
  159.         OrderAttackTactic(tactic,TRUE);
  160.  
  161. endstate;
  162.  
  163. //------------------------------------------------------------------
  164. //    RampageState: no targets remain -- let's kick some ass!
  165. //------------------------------------------------------------------
  166.  
  167. state RampageState;
  168.     code
  169.         if (GetTarget(ME) == NO_UNIT) then
  170.             FindEnemy(AttackRange,FT_DEFAULT);
  171.         endif;
  172.  
  173.         if (GetTarget(ME) <> NO_UNIT) then
  174.             if (attackSound <> -1) then    
  175.                 PlaySoundOnce(attackSound);
  176.             endif;
  177.  
  178.             OrderAttack(TRUE);
  179.         endif;
  180.  
  181. endstate;
  182.  
  183. //------------------------------------------------------------------
  184. //    DeadState: OK, I kicked the bucket.
  185. //------------------------------------------------------------------
  186.  
  187. state DeadState;
  188.     code
  189.         if (deathSound <> -1) then    
  190.             PlaySoundOnce(deathSound);
  191.         endif;        
  192.  
  193.         orderDie;
  194.  
  195. endstate;
  196.  
  197.  
  198. endfsm.
  199.  
  200.